//package com.xiaodai.miaosha.config;
//
//import com.xiaodai.miaosha.entity.Msuser;
//import com.xiaodai.miaosha.service.IUserService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.core.MethodParameter;
//import org.springframework.stereotype.Component;
//import org.springframework.web.bind.support.WebDataBinderFactory;
//import org.springframework.web.context.request.NativeWebRequest;
//import org.springframework.web.method.support.HandlerMethodArgumentResolver;
//import org.springframework.web.method.support.ModelAndViewContainer;
//
///**
// * 自定义用户参数
// *
// * @author: LC
// * @date 2022/3/3 4:46 下午
// * @ClassName: UserArgumentResolver
// */
//@Component
//public class UserArgumentResolver implements HandlerMethodArgumentResolver {
//
//    @Autowired
//    private IUserService itUserService;
//
//    @Override
//    public boolean supportsParameter(MethodParameter parameter) {
//        Class<?> parameterType = parameter.getParameterType();
//        return parameterType == Msuser.class;
//    }
//
//    @Override
//    public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
//
//        return UserContext.getMsuser();
//
//        //        HttpServletRequest nativeRequest = webRequest.getNativeRequest(HttpServletRequest.class);
////        HttpServletResponse nativeResponse = webRequest.getNativeResponse(HttpServletResponse.class);
////        String userTicket = CookieUtil.getCookieValue(nativeRequest, "userTicket");
////        if (StringUtils.isEmpty(userTicket)) {
////            return null;
////        }
////        return itUserService.getUserByCookie(userTicket, nativeRequest, nativeResponse);
//    }
//
//}
